package com.danco.training.zaneuskaya.service.comparator;

import java.io.Serializable;
import java.util.Comparator;

import com.danco.training.zaneuskaya.domain.Book;

public class BookComparatorByQuantity implements Comparator<Book>, Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7073676034591718762L;

	public int compare(Book o1, Book o2) {

		int q1 = o1.getQuantity();
		int q2 = o2.getQuantity();

		if (q1 > q2) {
			return 1;
		} else if (q1 < q2) {
			return -1;
		}
		return 0;
	}

}
